package org.candan.spider.bean;
import java.util.Date;
import java.util.Timer;

/**
 * @author ZhangShuCheng
 * @category 任务
 *
 */
public class Task {
	private String status; // 是否启用
	private String id ; //唯一标示
	private String name ; //
	private String url; //扒取地址
	private String output; //输出地址
	private Date startTime ; //开始时间
	private Date endTime ;//结束时间
	private String type; // 时间间隔类型
	private String space; // 时间间隔
	private long interval;// 时间间隔：换算成毫秒
//	private Date delayTime; // 延迟时间
//	private Date lastExecutTime; // 最新执行时间
	private Timer timer ;// 
	private DataSift datafilter;
	private TagSift tagFilter;
	
	public Task(String enable,String id,String name,String url,String output,Date startTime,
			Date endTime,String type,String space) {
		super();
		// TODO Auto-generated constructor stub
		this.status=enable;
		this.id=id;
		this.name=name;
		this.url=url;
		this.output=output;
		this.startTime=startTime;
		this.endTime=endTime;
		this.type=type;
		this.space=space;
		this.interval = Long.parseLong(this.space) * 10000;
		timer  = new Timer(""+id);
//		this.delayTime=delayTime;
//		this.lastExecutTime=lastExecutTime;
	}
	public DataSift getDatafilter() {
		return datafilter;
	}

	public void setDatafilter(DataSift datafilter) {
		this.datafilter = datafilter;
	}

	public TagSift getTagFilter() {
		return tagFilter;
	}

	public void setTagFilter(TagSift tagFilter) {
		this.tagFilter = tagFilter;
	}

	public Task(){
		super();
	}

	public long getInterval() {
		return interval;
	}

	public void setInterval(long interval) {
		this.interval = interval;
	}

	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public Timer getTimer() {
		if(timer == null){
			timer = new Timer(id);
		}
		return timer;
	}

	public void setTimer(Timer timer) {
		this.timer = timer;
	}


	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getOutput() {
		return output;
	}

	public void setOutput(String output) {
		this.output = output;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}


	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getSpace() {
		return space;
	}

	public void setSpace(String space) {
		this.space = space;
	}

//	public Date getDelayTime() {
//		return delayTime;
//	}
//
//	public void setDelayTime(Date delayTime) {
//		this.delayTime = delayTime;
//	}
//
//	public Date getLastExecutTime() {
//		return lastExecutTime;
//	}
//
//	public void setLastExecutTime(Date lastExecutTime) {
//		this.lastExecutTime = lastExecutTime;
//	}

	
//	/**
//	 * @category 删除这个方法
//	 * @param subClassName
//	 */
//	public void openTimerTask(String subClassName){
//		try {
//			SpiderTask timerTask = (SpiderTask) Class.forName(subClassName).newInstance();
//			timerTask.setTask(this);
//			timer.scheduleAtFixedRate(timerTask, this.startTime,interval); 
//			
//		} catch (InstantiationException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (IllegalAccessException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (ClassNotFoundException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
	}

}
